The invention pertains generally to debugging tools to support software applications for Java(trademark) platforms and, more particularly, to a debugging method and computer program product for debugging a target Java virtual machine (VM) which does not include the usual debug symbol information required by the debug interface/debugging protocol of a Java virtual machine (such as the standard Java Debugging Wire Protocol (JDWP)).
Software application development programs are typically equipped with debuggers (being a type of software tool) whose purpose it is to track for the user the execution steps taken when a target application program is run such that the debugger identifies the application program source or assembly code statements that have been executed during the debugging session, the values that have been assigned to variables at each step, etc. With the information generated by the debugger the user can more readily determine whether or not the application program ran as it was supposed to and, if not, identify the point in the application program which failed to properly execute as well as other execution tracking information such as the values of local variables, etc. For these reasons debugging tools are equally important for developing, testing and maintaining Java virtual machines and Java platforms comprising them as the application programs to be run on those platforms.
The remote (debugging of a Java virtual machine (VM) is typically done using the Java Debug Interface (JDI) application program interface (API) developed by Sun Microsystems, Inc. The JDI is a high-level Java programming language interface which includes support for remote debugging. The target virtual machine to be remotely debugged will also normally support the Java Virtual Machine Debug Interface (JVMDI) API which is a low-level native interface and defines the services a Java virtual machine must provide for debugging. Further, the underlying communications between a debugger and the virtual machine are typically done using the standard debug protocol developed for Java applications, known as the Java Debug Wire Protocol (JDWP), in which case the virtual machine only needs to know the JDWP which defines the format of information and requests transferred during the debugging process between the virtual machine and the debugger front-end.
According to the standard debug protocol (JDWP) it is assumed that the target virtual machine will have complete information about class names, field names, line number information for each method, local variables, etc. (this information usually being present in class files compiled to have debug information), and this assumption implies that the target virtual machine must comprise class files having as much debug information as possible. It also requires that the virtual machine be packaged without the removal of fully qualified names even if they are not needed (such as when, for instance, reflection is not used by the program).
The JDI, as specified by Sun Microsystems, supports both line and instruction-based stepping but the former, which is typically preferred by application developers, requires that a much greater amount of debug information, including line number tables, be made available. Line-based debug requests require the use of these line number tables to translate line-based requests into the corresponding instruction-based requests which are actually required by the virtual machine for execution. To provide for this translation the Java compiler provides a set of line number tables in the usual compiler-generated debug information and these tables generally make up a large percentage of the total size of the debug information. The information provided by these tables is used by the virtual machine to translate any line-based request received from the debugger to an instruction-based request. For example, two lines of a source code program which a debugger might step over could be: Line 1: a=1+2 and Line 2: a=a+1, whereas the virtual machine will actually execute the following four instruction-level step operations for each line instruction:
C compilers which compile application programs produce both a xe2x80x9cfat debugxe2x80x9d image having all the required debug information and a xe2x80x9cnormalxe2x80x9d, non-debug counterpart so that after the desired debugging has been completed the non-debug program, usually being smaller than the debug version, can instead be installed for use. However, this method is not suitable for embedded Java programs, representing a likely environment for Java virtual machines, because the target program would then have to contain all the necessary debug information in class files and this debug information may require substantial space (memory) which may not be available in the embedded environment. Well-designed embedded products are intentionally xe2x80x9cright-sizedxe2x80x9d to consume all target platform resources and, thus, the inclusion of additional debug information in such a virtual machine will typically not work in a production system (i.e. either because there is no extra memory on which such extra information may reside or because the use of extra memory would impair program execution).
The present invention addresses and resolves the foregoing problem posed by the limited memory resources in the production environments of embedded virtual machines for which it may not be possible to include debug information in the virtual machine bytecodes.
In accordance with the present invention there is provided a method for debugging a virtual machine without need for the virtual machine to comprise debug information required by a debugger, the method being applied during communication of request packets between the debugger and the virtual machine during execution of the debugger, the method comprising the steps of receiving the request packets from the debugger prior to communication of the request packets to the virtual machine, processing the request packets whereby the required debug information is provided to predetermined packets thereof, transmitting the processed request packets for communication to the virtual machine, receiving reply packets from the virtual machine, processing the reply packets for reply to the debugger, and transmitting the processed reply packets to the debugger. The method may be further provided wherein the virtual machine is a target Java virtual machine. Also, the method may be further comprise the step of providing a proxy comprising the debug information separate from the virtual machine and for performing the processing, receiving and transmitting steps. Further, the preceding method may comprise as a preliminary step, the step of transferring the debug information from the virtual machine into the proxy. Or, the preceding method may further comprise as a preliminary step, the step of packaging an image of the virtual machine comprising the debug information and incorporating the image into the proxy. The method may also be provided wherein the debug information comprises line tables and the step of processing request packets comprises translating line-based request packets to instruction-based request packets. The method may also be provided wherein the format of the request packets is defined by the Java Debug Wire Protocol (JDWP). And the predetermined request packets may be those packets determined to require debug information in the proxy.
There is also provided a computer program product for use in debugging a virtual machine without need for the virtual machine to comprise debug information required by a debugger, the computer program product comprising the debug information, means for receiving request packets from the debugger prior to communication of the request packets to the virtual machine, means for processing the request packets whereby required debug information is provided to predetermined packets thereof, means for transmitting the processed request packets for communication to the virtual machine, means for receiving reply packets from the virtual machine, means for processing the reply packets for reply to the debugger, and means for transmitting the processed reply packets to the debugger. The computer program product may also be provided wherein the virtual machine is a target Java virtual machine. Further, the computer program product may be provided wherein the debug information comprises line tables and the means for processing request packets comprises means for translating line-based request packets to instruction-based request packets. The computer program product may also be provided wherein the format of the request packets is defined by the Java Debug Wire Protocol (JDWP). And, the predetermined request packets may be those packets determined to require debug information. The computer program product according to claim 9 wherein the debug information is defined by a symbol file.
Further, there is provided an article of manufacture comprising a computer usable medium having computer readable, program code means therein for debugging a virtual machine without need for the virtual machine to comprise debug information required by a debugger, the computer readable program code means in said article of manufacture comprising the debug information, computer readable code means for causing a computer to effect receiving request packets from the debugger prior to communication of the request packets to the virtual machine, computer readable code means for causing a computer to effect processing the request packets whereby the required debug information is provided to predetermined packets thereof, computer readable code means for causing a computer to effect transmitting the processed request packets for communication to the virtual machine, computer readable code means for causing a computer to effect receiving reply packets from the virtual machine, computer readable code means for causing a computer to effect processing the reply packets for reply to the debugger, and computer readable code means for causing a computer to effect transmitting the processed reply packets to the debugger. The article of manufacture may be further provided wherein the virtual machine is a target Java virtual machine. Additionally, the article of manufacture may be provided wherein the debug information is transferred from the virtual machine. Also, the article of manufacture may be provided wherein the debug information is an image of the virtual machine. Further, the article of manufacture may be provided wherein the debug information comprises line tables and the step of processing request packets comprises translating line-based request packets to instruction-based request packets. Also, the article of manufacture may be provided wherein the format of the request packets is defined by the Java Debug Wire Protocol (JDWP). And, the predetermined request packets may be those packets determined to require debug information.
In addition, there is provided a computer program product for use in debugging a Java virtual machine without need for the Java virtual machine to comprise debug information required by a debugger, the computer program product comprising the debug information, means for receiving request packets from the debugger prior to communication of the request packets to the Java virtual machine, means for processing the request packets whereby required debug information is provided to predetermined packets thereof, means for determining whether the request packets are required to be transmitted to the Java virtual machine and if not so required, transmitting reply packets to the debugger, means for transmitting, if so required, the processed request packets for communication to the Java virtual machine, means for receiving reply packets from the Java virtual machine, means for processing the reply packets for reply to the debugger, and means for transmitting the processed reply packets to the debugger.
Also provided is a computer program product for use in debugging a Java virtual machine without need for the Java virtual machine to comprise debug information required by a debugger, the computer program product comprising the debug information, means for receiving request packets from the debugger prior to communication of the request packets to the Java virtual machine, means for processing the request packets whereby required debug information is provided to predetermined packets thereof, means for transmitting the processed request packets for communication to the Java virtual machine, means for receiving reply packets from the Java virtual machine, means for determining whether additional information is needed by the Java virtual machine and if so needed, transmitting one or more request packets to the Java virtual machine and receiving one or more reply packets from the Java virtual machine until the additional information is obtained, means for processing the reply packets for reply to the debugger, and means for transmitting the processed reply packets to the debugger.